// Zinc, the bare metal stack for rust.
// Copyright 2015 zinc developers <http://zinc.rs>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MODIFY IT DIRECTLY, UPDATE THE
// SVD DEFINITION IN SUPPORT/SVD/DATA AND RE-GENERATE, ADDING THE CHANGES MADE
// INTO THE RELEVANT CHANGELOG ENTRY.

//! ioregs definition based on <%= @filename %>

use volatile_cell::VolatileCell;
use core::ops::Drop;

<% @svd.peripherals.each do |peripheral| %>
ioregs! (<%= peripheral.name %> @ <%= peripheral.base_address.to_hex %> = {  //! <%= peripheral.description %>
  <% peripheral.registers.each do |reg| %>
  <%= reg.offset.to_hex %> => reg<%= reg.size %> <%= reg.name %> {  //! <%= reg.description %>
    <% reg.fields.each do |f| %>
    <% unless f.enums.empty? %>
    <%= f.bits_string %> => <%= f.name %><%= @map_access.call(f.access) %> {  //! <%= f.description %>
      <% f.enums.each do |e| %>
      <% if !e.name['RESERVED'] %>
      <%= e.value %> => <%= e.name %>,  //= <%= e.description %>
      <% end %>
      <% end %>
    }
    <% else %>
    <%= f.bits_string %> => <%= f.name %><%= @map_access.call(f.access) %>,  //= <%= f.description %>
    <% end %>
    <% end %>
  },
  <% end %>
});
<% end %>
